<template>
  <div>
    <x-header id="header" :left-options="{backText: ''}">平台消息</x-header>
    <div class="main-header">
      <div class="message" v-for="(item, index) in msgList" :key="index" @click="goDetail">
        <!--<img class="message-icon" src="../../../static/img/sysMsg.png" />-->
        <img class="message-icon" src="item.picture" />
        <div class="message-body">
          <div class="message-body-up">
            <div class="message-body-title">{{item.title}}</div>
            <div class="message-body-day">{{item.updateTime}}</div>
          </div>
          <div class="message-body-content">{{item.content}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getSystemMessageList } from '@/api/message'
export default {
  name: 'sysMsg',
  data () {
    return {
      cp: 1,
      lp: 1,
      msgList: []
    }
  },
  methods: {
    goDetail () {
      this.$router.push({
        name: 'msgDetail',
        query: {
          id: 1
        }
      })
    },
    getList (pageId) {
      getSystemMessageList(pageId).then( data => {
        this.cp = data.current_page
        this.lp = data.last_page
        this.msgList = [...this.msgList, ...data.data]
      })
    }
  },
  mounted () {
    getSystemMessageList().then( data => {
      this.cp = data.current_page
      this.lp = data.last_page
      this.msgList = data.data
    })
  }
}
</script>

<style scoped>
.message {
  background: #fff;
  border-bottom: 0.5px solid #eee;
  padding: 1rem 1.5rem;
  display: flex;
}
.message-icon {
  height: 3.5rem;
  width: 3.5rem;
  margin-right: 1rem;
}
.message-body {
  flex:1
}
.message-body-up {
  display: flex;
  margin-bottom: 0.4rem;
}
.message-body-title {
  color: #4A4A4A;
}
.message-body-day {
  flex: 1;
  text-align: right;
  font-size: 12px;
  color: #9B9B9B;
}
.message-body-content {
  font-size: 12px;
  color: #9B9B9B;
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
</style>
